<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色列表</title>
<link href="/resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="/resources/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="/resources/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ex/ligerGrid.showFilter.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ex/ligerFilterEx.js" type="text/javascript"></script>
<script type="text/javascript">
        var $grid;
        var form;
        $(function (){
            //创建表格对象
            $grid = $("#maingrid").ligerGrid({
                columns: [
                { name: 'uuid', hide:true,type:"text"},
                { display: '角色编号', name: 'roleNum', width: 100,type:"text"},
                { display: '角色名', name: 'roleName', width: 100,type:"text"},
                { display: '备注', name: 'remark', width: 100,type: "text"}
                ],
                autoFilter:true,
                width: '100%', pageSizeOptions: [5, 10, 15, 20], height: '100%',
                checkbox: true,headerRowHeight:22, rowHeight:22, rownumbers:true,
                url:'/sysRole/listData',
                onLoadData:onloadData,
                onDblClickRow:onDblClickRow,
                toolbar: { items: [
                                   { text: '新增', click: addClick, icon: 'add' },
                                   { line: true },
                                   { text: '修改', click: alertClick, icon: 'modify' },
                                   { line: true },
                                   { text: '删除', click: delClick, icon: 'delete' }
                                   ]
                                   }
            });

        });
        //添加
        function addClick(item){
        	f_addTab('operationRole_add','新增角色','/sysRole/addSysRole');
        }
        //双击事件(查看)
        function onDblClickRow(data, rowindex, rowobj){
        	f_addTab('operationRole_view','查看角色','/sysRole/viewSysRole?uuid='+data.uuid);
        }
        
        //删除
        function delClick(){
        	var rows = $grid.getSelectedRows();
        	if(rows == null || rows.length < 1){
        		$.ligerDialog.error("请至少选择一行数据");
        		return;
        	}
    		$.ajax({ 
    			url: '/sysRole/delSysRole', 
    			data:{rows : JSON.stringify(rows)}, 
    			type: "post", 
    			dataType:'json',
    			cache : false, 
    			success: function(data){
    				$.ligerDialog.success(data.message,'信息',function(){
    		        	 $grid.reload();
    				});
    			},
    	        error: function (message) {
    	            $.ligerDialog.error("删除失败");
    	        }
    	});
        }
        //修改
        function alertClick(){
        	var rows = $grid.getSelectedRows();
        	if(rows == null || rows.length < 1 || rows.length != 1){
        		$.ligerDialog.error("请选择一条要修改的数据");
        		return;
        	}
    		f_addTab('operationRole_alert','修改角色','/sysRole/alertSysRole?uuid='+rows[0].uuid);
        }
        //查询
        function viewClick(){
        	//重新加载grid
        	 $grid.reload();
        }
        
    	//添加窗口
        function f_addTab(tabid,text, url){
    		this.parent.f_addTab(tabid,text, url);
        } 
        
      //通知子页面发送数据变更，父页面需要刷新数据
        function noticeTabRefresh(){
        	$("#form2").submit();
        }
      //获取数据前添加过滤条件
      function onloadData(){
    	 /*  var cond = JSON.stringify(form.getData());
    	  this.set('parms', [{ name: "cond", value: cond, temp: true }]); */
      } 
    </script>
</head>
<body  style="padding:10px">
	<form id="form2" action="/sysRole/toSysRoleList" method="post"></form> 
    <div id="maingrid"></div> 
</body>
</html>
